#ifndef prs_FrmPageControl_H
#define prs_FrmPageControl_H

#include "prs_FrmFunc.h"
#include "prs_Rule.h"
#include "prs_FrmRules.h"
#include "prs_FrmGeom.h"
#include "prs_FrmControl.h"
#include "prs_FrmButtonStyle.h"
#include "prs_FrmPageControlStyle.h"
#include "frm_control_TPageControl.h"

namespace prs {

///////////////////////////////////////////////////////////////////////////////

struct TNodeFrmPageControl : public TNodeFrmControl
{
  DECLARE_ClientNode()
  //
  typedef TNodeFrmPageControlStyle   TStyle;
  typedef frm::control::TPageControl TControl;
  //
  TAttrNodeType<nodeType_PageControl> NodeType;
  TAttrEnum<attrName_Orient,TFrmPageOrient,TFrmPageOrient::Enum> Orient;
  TAttrPointerNoCopy<attrName_Control,frm::control::TPageControl*> Control;
  //
  TNodeFrmPageControl() : NodeType(this),Control(this),Orient(this) {}
 ~TNodeFrmPageControl() { delete Control.GetValue();}
  //
  frm::control::TPageControl *BuildControl(
    frm::control::TPanel *ParentControl
  );

private:
  void SetOrient();
};
                   
///////////////////////////////////////////////////////////////////////////////

struct TRuleFrmPageControl : public snt::TRule , public TFrmDict
{
  TRuleFrmPageControl(
    snt::text::TContext &Context,
    svl::TVariant &VParentNode,
    TRuleFrmChildrenBase &RChildren,
    TRuleSetNodeIdOptionally &RSetNodeIdOptionally,
    TRuleSetAttrValue &RSetAttrValue,
    TRuleFrmGeom &RFrmGeom,
    TRuleSetStyle &RStyle
  );

private:  
  TNodeFrmPageControl *GetNode() { return dynamic_cast<TNodeFrmPageControl*>(vParentNode.Pointer());}
  void FSetGeometry(snt::TParams &Params) { rGeometry.SetGeom( &GetNode()->Geometry.Value );}
  //
  bool FSetParam(TRuleSetAttrValue::TFuncValueIdentParams &Params);
  //
  svl::TVariant &vParentNode;
  TRuleFrmGeom &rGeometry;
  snt::TRule  RAttr,RAttr1;
  snt::TAlter AAttr1;
  svl_Except;
};

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

struct TNodeFrmPageButton : public TNodeFrmControl
{
  DECLARE_ClientNode()
  //
  typedef TNodeFrmButtonStyle       TStyle;
  typedef frm::control::TPageButton TControl;
  //
  TAttrNodeType<nodeType_PageButton> NodeType;
  TAttrPointerNoCopy<attrName_Control,frm::control::TPageButton*> Control;
  //
  TNodeFrmPageButton() : NodeType(this),Control(this) {}
  //
  void operator = (const TNodeFrmPageButton &From) { CopyAttrFrom(&From);}
};

///////////////////////////////////////////////////////////////////////////////

struct TNodeFrmPage : public TNodeFrmControl
{
  DECLARE_ClientNode()
  //
  typedef TNodeFrmPageStyle   TStyle;
  typedef frm::control::TPage TControl;
  //
  TAttrNodeType<nodeType_Page> NodeType;
  TAttrPointerNoCopy<attrName_Control,frm::control::TPage*> Control;
  TAttrNodeObject<attrName_Control,TNodeFrmPageButton> Button;
  //
  TNodeFrmPage() : NodeType(this),Control(this),Button(this) {}
 ~TNodeFrmPage() { delete Control.GetValue();}
};
                   
///////////////////////////////////////////////////////////////////////////////

struct TRuleFrmPage : public snt::TRule
{
  TRuleFrmPage(
    snt::text::TContext &Context,
    svl::TVariant &VParentNode,
    TRuleFrmChildrenBase &RChildren,
    TRuleSetNodeIdOptionally &RSetNodeIdOptionally,
    TRuleFrmGeom &RFrmGeom,
    TRuleSetStyle &RStyle
  );

private:  
  TNodeFrmPage *GetNodePage() { return dynamic_cast<TNodeFrmPage*>(vParentNode.Pointer());}
  void FSetGeometryPage(snt::TParams &Params) { rGeometry.SetGeom( &GetNodePage()->Geometry.Value );}
  //
  TNodeFrmPageButton *GetNodeButton() { return dynamic_cast<TNodeFrmPageButton*>(vParentNode.Pointer());}
  void FSetButton (snt::TParams &Params) { vParentNode = &GetNodePage()->Button.Value;}
  void FSetGeometryButton(snt::TParams &Params) { rGeometry.SetGeom( &GetNodeButton()->Geometry.Value );}
  //
  svl::TVariant &vParentNode;
  TRuleFrmGeom &rGeometry;
  snt::TRule  RAttr,RAttr1,RButtonAttr,RButtonAttr1,RButton;
  snt::TAlter AAttr1,AButtonAttr1;
  svl_Except;
};

///////////////////////////////////////////////////////////////////////////////
}

#endif
